﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_case_Sort : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["ID"] != null)
            {
                BindModel(Convert.ToInt32(Request["ID"]));
            }
        }
    }

    protected void BindModel(int ID)
    {
        KeMei.BLL.ProductAndCase bll = new KeMei.BLL.ProductAndCase();

        try
        {
            KeMei.Model.ProductAndCase model = bll.GetModel(ID);

            if (model != null)
            {
                txtSortNum.Text = model.Taxis.ToString();
            }
        }
        catch (Exception ex)
        {

            ExtAspNet.Alert.Show("绑定实体类失败：" + ex.Message);
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        KeMei.BLL.ProductAndCase bll = new KeMei.BLL.ProductAndCase();

        try
        {
            int ID = Convert.ToInt32(Request["ID"]);

            int sortNum = Convert.ToInt32(txtSortNum.Text);

            if (bll.ExistsNum(ID, sortNum, " and lmID in(select ID from Syslm where ParentID=2)"))
            {
                ExtAspNet.Alert.Show("排序数字已存在");
                return;
            }

            bll.UpdateTaxis(ID, sortNum);

            ExtAspNet.Alert.Show("保存成功！", String.Empty, ExtAspNet.Alert.DefaultIcon, ExtAspNet.ActiveWindow.GetHidePostBackReference());
        }
        catch (Exception ex)
        {

            ExtAspNet.Alert.Show("修改排序失败：" + ex.Message);
        }
    }
}